<template>
  <el-dialog :visible.sync="visible" v-dialogDrag title="任务作废" width="800px" top="200px" :close-on-click-modal="false" class="tl-dialog" @open="open" @close="close" :append-to-body="true" :modal-append-to-body="true">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="120px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="作废原因" prop="backreason" :rules="rules.validateRequire">
            <el-input v-model="model.backreason" type="textarea" :rows="2"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
  </el-dialog>
</template>
<script>
/** mixins */
import { mixin_edit } from "@tapui/mixins/mixin_edit"
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from "@tapui/utils/http"
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      urlPrefix: "/meet/taskManage/",
      url: {
        // 额外的url
        queryCodeList: "",
        drop: "/meet/taskManage/drop"
      },
      taskObj: {}
    }
  },
  props: {},
  methods: {
    loaded() {},
    open() {
      this.$set(this.model, "backreason", "")
    },
    doSubmitEdit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.doDrop()
        } else {
          return false
        }
      })
    },
    doDrop() {
      const { usercode, deptcode, orgcode, id } = this.taskObj
      const param = {
        usercode,
        deptcode,
        orgcode,
        backreason: this.model.backreason,
        sourceid: id
      }
      this.saveLoading = true
      postAction(this.url.drop, param)
        .then((res) => {
          if (res.success) {
            this.$tap.message(res.message)
            this.visible = false
            this.$emit("refresh")
          } else {
            this.$tap.alert(res.message, "warning")
          }
          this.saveLoading = false
          this.afterSubmit()
        })
        .catch((err) => {
          this.saveLoading = false
        })
    }
  }
}
</script>
